#!/usr/bin/env xonsh 

from fire import Fire

@Fire
def main(dirpath):
  cd @(dirpath)
  #fileli = $(find @(dirpath)/*.json.gz).split()
  #rm -rf voip
  #for i in fileli:
  #  outfile=i[:-8]
  #  print(outfile)
  #  pigz -dc @(i)|rg voip_call|jq -r '.sessionTimestamp[:-3]+","+.eventParameters.voip_call+","+.userId+","+.deviceIdentifiers.AndroidId' > @(outfile) 
  #  cat @(outfile) >> voip
  #  
  #(echo "sessionTimestamp,voip,userId,android_id" && sort -n voip|uniq) > voip.csv
  rm voip.db
  (echo .mode csv;echo .import voip.csv voip)|sqlite3 voip.db
  zstd -19 --rm voip.db
  scp voip.db.zst r5:/root/zst/ 

#rm -rf voip.csv



# (echo "sessionTimestamp,voip,userId,android_id" && sort -n $1|uniq) > voip.csv
# rm $1
#(echo .mode csv;echo .import %s %s)|sqlite $0
#rsync -av ./zst/ r5:/root/zst
